/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.msk.sys.service;


import com.msk.sys.domain.Office;
import com.msk.sys.mapper.OfficeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;

/**
 * 机构Service
 * @author ThinkGem
 * @version 2014-05-16
 */
@Service
@Transactional(readOnly = true)
public class OfficeService extends CrudService<OfficeDao, Office> {

	@Autowired
	private OfficeDao officeDao;

	public List<Office> findAll() {
		List<Office> officeList = officeDao.findAllList(new Office());
		return officeList;
	}

	@Transactional(readOnly = true)
	public List<Office> findList(Office office) {
		if (office != null) {
			office.setParentIds(office.getParentIds()+office.getId() + "%");
			return dao.findByParentIdsLike(office);
		}
		return new ArrayList<Office>();
	}


	@Transactional(readOnly = true)
	public List<Office> findListOnly(Office office) {
		return dao.findOnlyList(office);
	}


	@Transactional(readOnly = false)
	public void save(Office office) {
		super.save(office);
	}

	@Transactional(readOnly = false)
	public void delete(Office office) {
		super.delete(office);
	}

	/**
	 * @description findCodeById
	 * @date 2018-8-1
	 * @author chuming
	 * @param id
	 * @return
	 */
	public String findCodeById(String id) {
		return dao.findCodeById(id);
	}

	/**
	 *
	 * @description findListByCode
	 * @date 2018-9-12
	 * @author chuming
	 * @param office
	 * @return
	 */
	public Office findListByCode(Office office) {
		return dao.findListByCode(office);
	}

	/**
	 *
	 * @description findListByMobile
	 * @date 2018-9-12
	 * @author chuming
	 * @param office
	 * @return
	 */
	public List<Office> findListByMobile(Office office) {
		return dao.findListByMobile(office);
	}

}
